<%@page import="com.xbk.jtable.ui.HtmlUtil"%>
<%@page import="com.xbk.jtable.ui.jForm"%>
<%@page import="com.xbk.jtable.ui.jTableUtil"%>
<%@page import="com.xbk.platform.DataMap"%>
<%@page import="com.xbk.util.StringUtil"%>
<%@page import="com.xbk.jtable.ui.Widget"%>
<%@page import="com.xbk.jtable.ui.jTable"%>
<%@page import="com.xbk.platform.DaoUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/Include/include.jspf"%>
<style type="text/css">
</style>
<%
	DaoUtil du = ConnectionMananger.getDaoUtil();
	String sInterfaceID = request.getParameter("interfaceID");
	
	String jtableData = "";
	DataMap inter = new DataMap(); 
	
	String sSql = "SELECT RULEID,OBJECTNO,RULE_TYPE,EXPRESSION,REMARK,FIELDS FROM DCP_RULE_DEL WHERE OBJECTNO = '"+sInterfaceID+"'";
	jTable jtable = new jTable(du);
	jtable.setRelativeTable("DCP_RULE_DEL");
	jtable.initBySql(sSql);
	jtable.setHeader(du.getCols(sSql));
	jtableData = jtable.getHtml();
	
	du.close();
%>
</head>
<body>
<!-- top -->
<div id="top">
	<%@include file="/top.jsp" %>
</div>

<form class="ml20 form-inline" action="RuleCheck.jsp" method="get">
<%=HtmlUtil.getSelectOptions("SELECT INTERFACENAME AS K,INTERFACEID AS V FROM DCP_INTERFACE_DEF","选择接口文件", "interfaceID", "interfaceID", sInterfaceID) %>
<label for="CodeNo">或者
<input type="text" name="CodeNo" class="mb0" placeholder="输入一个表名查询,支持模糊">
<button class="btn">确定</button>
</label>
</form>

<!-- content -->
<div id="jtableContainer" class="mg20 mt100 mb0"></div>
</body>
<script type="text/javascript">
	$(function(){
		var jtable = new jDcp.web.Table();
		jtable.parse("<%=jtableData %>");
		jtable.appendTo("jtableContainer");
		
		jtable.hideModelRow("当前接口文件没有任何规则被指定！");
		
		var button = {};
		button.text = "规则校验";
		button.title = "默认校验当期数据";
		button.cls = "btn";
		button.fn = function(){
			var rules = jtable.getColValues("RULEID");
			var interfaceID = $("#interfaceID").val();
// 			var option = {};
// 			option.rules = rules.join(",");
// 			option.action = "doCheck";
// 			option.interfaceID = interfaceID;
// 			option.rand = Util.getRandom();
			window.open("RuleCheckResult.jsp?rules="+rules+"&interfaceID="+interfaceID+"&rand="+Util.getRandom(),"newwindow",'height=700,width=1360,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
// 			$.post("/DCP3/rule",option,function(data){
// 				if(data != null){
// 					if(window.confirm("共检查出  "+data+"条错误记录，是否立即进行补录？")){
// 						window.open("RuleCheckResult.jsp","newwindow",'height=700,width=1360,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
// 					}
// 				}
// 			});
		};
		button.img = "icon-check";
		jtable.addButton(button);
		
		var viewData = {};
		viewData.text = "查看历史数据";
		viewData.cls = "btn";
		viewData.fn = function(){
			var inputdate = window.prompt("请输入数据日期");
			alert(inputdate);
		};
		viewData.img = "icon-search";
		jtable.addButton(viewData);
		
		viewData = {};
		viewData.text = "查看当期数据";
		viewData.cls = "btn btn-primary";
		viewData.fn = function(){
			window.open("ViewData.jsp?rand="+Util.getRandom(),"newwindow",'height=700,width=1360,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
		};
		viewData.img = "icon-search icon-white";
		jtable.addButton(viewData);
		
		jtable.hideCols({col:"INTERFACEID"});
		$(".jtable-container").css("height",(($(window).height() - $(".jtable-container").offset().top) - 25) + "px");
		
		//隐藏字段
		jtable.hideCols({col:"RULEID,OBJECTNO"});
		
		//隐藏按钮
		jtable.hideButton(jDcp.web.Table.BUTTON_ADD);
		jtable.hideButton(jDcp.web.Table.BUTTON_DELETE);
		jtable.hideButton(jDcp.web.Table.BUTTON_SAVE);
		
		//禁止编辑jTable
		jtable.setEdit(false);
		
		//插入自定义的字段
		jtable.insertCol("<td class='stay-center'><input type='checkbox' checked='checked'></input></td>","是否选用",1);
		
// 		jtable.setRowColor(1,"success");
// 		jtable.setRowColor(2,"error");
		
		$("#interfaceID").change(function(){
			var interfaceID = $(this).val();
			window.location.replace("RuleCheck.jsp?interfaceID="+interfaceID+"&rand="+Util.getRandom());
		});
	});
</script>
</html>